package up6.store;

import java.io.ByteArrayOutputStream;
import org.apache.commons.fileupload.FileItem;

import up6.PathTool;
import up6.model.FileInf;

public class DfsBlockWriter extends FileBlockWriter{

    public DfsBlockWriter() {
        this.storage=StorageType.FastDFS;
    }

    public String make(FileInf file)
    {
        String fileID="";
        String ext = PathTool.getExtention(file.pathSvr);
        byte[] buf = new byte[0];
        fileID = FastDFSTool.upload(buf, ext);
        return fileID;
    }

    /**
     * 参数：pathSvr
     */
    public String write(FileInf file, ByteArrayOutputStream ostm)
    {
        byte[] data = ostm.toByteArray();
        if(FastDFSTool.write(file.fastdfs_id, data)) return "ok";
        return "";
    }
}
